package com.ning.controller;

import com.ning.mapper.UserMapper;
import com.ning.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    //查询所有信息
    private UserMapper userMapper;
    @GetMapping("/queryUserList")
    public List<User> queryUserList(){
        List<User> userList = userMapper.queryUserList();
        for (User user : userList) {
            System.out.println(user);
        }
        return userList;
    }
    @GetMapping("/addUser")//添加数据啊
    public String addUser(){
        userMapper.addUser(new User(6,"我是真服","asd123"));
        return "add ok!";
    }
    @GetMapping("/updateUser")//通过id修改数据库
    public String updateUser(){
        userMapper.updateUser(new User(6,"发顺丰啊","qwe123"));
        return "updateUser ok!";
    }
    @GetMapping("/deleteUser")//通过id删除数据库
    public String deleteUser(){
        userMapper.deleteUser(6);
        return "deleteUser ok!";
    }




}
